package com.ruoyi.web.controller.openfeignTwo;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.dto.FileDTO;
import com.ruoyi.web.controller.openfeign.FileClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("/file/two")
public class FeignControllerTwo {

    @Autowired
    private FileClientTwo fileClientTwo;

/*
    @PostMapping("/fetch")
    public AjaxResult fetchFile(@RequestBody FileDTO fileDTO) {
        try {
            // 从 FileDTO 获取 fileUrl
            String url = fileDTO.getFileUrl();
            if (url == null || url.isEmpty()) {
                return AjaxResult.error("URL 参数不能为空");
            }

            // 创建请求 Map，确保键名为 "file_url"
            Map<String, String> request = new HashMap<>();

            request.put("file_url", url);

            // 远程调用 Feign Client
            Map<String, Object> fileInfo = fileClientTwo.getFile(request);



            System.out.println("我是哈哈哈"+request);



            // 检查返回值
            if (fileInfo != null && fileInfo.containsKey("result_file_url")) {
                return AjaxResult.success(fileInfo);
            } else {
                return AjaxResult.error("文件获取失败，URL 可能无效");
            }
        } catch (Exception e) {
            return AjaxResult.error("服务器错误：" + e.getMessage());
        }
    }
*/


}
